package edu.hawaii.myisern.model;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
 * Tests the user class.
 * 
 * Attributed and Inspired by Tim Fennell.
 * 
 * @author Ed Kim
 * @author Jon Lao
 * @author Jianfei Liao
 * @author Jared Sunouchi
 */
public class TestUser {
  
  /**
   * Tests.
   *
   * @throws Exception If problems occur
   */
  @Test
  public void testUser() throws Exception {
    User defaultUser = new User();
    
    defaultUser.setUsername("username");
    assertEquals("test equal username", "username", defaultUser.getUsername());
    
    defaultUser.setPassword("password");
    assertEquals("test equal password", "password", defaultUser.getPassword());
    
    String number = "9";
    int intNum = Integer.parseInt(number);
    
    defaultUser.setId(Integer.valueOf(intNum));
    assertEquals("test equal id", Integer.valueOf(intNum), defaultUser.getId());
    
    User overloadedUser = new User("username","password");
    overloadedUser.getPassword();
    
    // test override methods
    assertEquals("test the equals method", defaultUser, defaultUser);
    
    int hash = defaultUser.hashCode();
    assertEquals("test the hashCode method", 1283819926, hash);
  }
}
